package zjh_20230328;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

public class Test {
    public static void main(String[] args) throws SQLException {
//        String url = "jdbc:mysql://localhost:3306/store";
//        String usr = "root";
//        String password = "";
//        DBUtils<Category> objectDBUtils = new DBUtils<>(url,usr,password);

        //用配置文件实现，不用谢url、usr、password，配置文件写好了都
        String str = "SELECT no,name FROM category";
        DBUtils<Category> objectDBUtils = new DBUtils<>();
        List<Category> select1 = objectDBUtils.Select(str, Category.class);
        System.out.println(select1);


//        ResultSet resultSet = objectDBUtils.excuteQuery(str);
//        ResultSetMetaData metaData = resultSet.getMetaData();
//        int columnCount = metaData.getColumnCount();
//        while (resultSet.next()) {
//            for (int i = 0; i < columnCount; i++) {
//                Object value = resultSet.getObject(i + 1);
//                String columnLabel = metaData.getColumnLabel(i + 1);
//                System.out.println(columnLabel + "-----" + value);
//            }
//        }


        try {
            List<Category> select = objectDBUtils.Select(str, Category.class);
            System.out.println(select);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
